package com.mall.dubbo.api;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.mall.dubbo.mappers.UmsAdminMapper;
import com.tanhua.model.domain.UmsAdmin;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.DigestUtils;

@DubboService
public class UmsAdminApiImpl implements UmsAdminApi {

    @Autowired
    private UmsAdminMapper umsAdminMapper;



    /**
     * 根据 账号 密码查找
     * @param username
     * @param password
     * @return
     */
    @Override
    public UmsAdmin findOne(String username, String password) {
        LambdaQueryWrapper<UmsAdmin> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(UmsAdmin::getUsername,username).eq(UmsAdmin::getPassword, DigestUtils.md5DigestAsHex(password.getBytes()));
        UmsAdmin ums_admin = umsAdminMapper.selectOne(lambdaQueryWrapper);
        return ums_admin;
    }

    /**
     * 根据 id查找账号
     * @param id
     * @return
     */
    @Override
    public UmsAdmin findById(Long id) {
        return umsAdminMapper.selectById(id);
    }
}
